package form2;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;

import FMS.Form2;
import FMS.Form4;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class ViewForm2 extends WebPage {

	public ViewForm2() throws IOException, SQLException {
		Reader reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		
		Form form = new Form("ViewForm2form");
		
        List<Form2> list = (List<Form2>)sqlMap.queryForList("Form2.getAll");
		
		ListView eachRecord = new ListView("eachRecord", list) {
			
        private static final long serialVersionUID = 1L;
			
			protected void populateItem(ListItem item) {
				final Form2 form2 = (Form2) item.getModelObject();
				item.add(new Label("promissoryNo", form2.getPromissoryNo()));
				item.add(new Label("name", form2.getName()));
				item.add(new Label("date", form2.getDate()));
				item.add(new Label("amount", form2.getAmount()));
				item.add(new Label("semester", form2.getSemester()));
				item.add(new Label("sy", form2.getSy()));
				item.add(new Label("dueDate", form2.getDueDate()));
				item.add(new Label("course", form2.getCourse()));
				item.add(new Label("year", form2.getYear()));
				item.add(new Label("witness", form2.getWitness());
			
            }
      }
		
		form.add(eachRecord);
		add(form);
}